package me.ywd.hystrix.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @Author Ye_Wenda
 * @Date 8/9/2017
 */
@Service
public class HytrixRibbonDemoService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "failSafe")
    public String consume() {
        return restTemplate.getForObject("http://provider/services", String.class);
    }

    public String failSafe() {
        return "Fail Safe";
    }
}
